home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v8n20.arc / MPSUB.ASM < prev    next >
Assembly Source File  |  1989-10-26  |  1KB  |  44 lines

  1.         title   MPSUB.ASM Multiple-Precision Integer Subtraction
  2.         page    55,132
  3.  
  4. ; MPSUB.ASM     Multiple-Precision Integer Subtraction
  5. ;               for Intel 8086, 8088, 80286, and
  6. ;               80386 in real mode/16-bit protected mode
  7. ;
  8. ; Copyright (C) 1989 Ziff Davis Communications
  9. ; PC Magazine * Ray Duncan
  10. ;
  11. ; Call with:    DS:SI   = address of source operand
  12. ;               ES:DI   = address of destination operand
  13. ;               CX      = operand length in bytes
  14. ;               Assumes direction flag is clear at entry
  15. ;
  16. ; Returns:      ES:DI   = address of result (destination - source)
  17. ;
  18. ; Destroys:     AL, CX, SI (other registers preserved)
  19.  
  20. _TEXT   segment word public 'CODE'
  21.  
  22.         assume  cs:_TEXT
  23.  
  24.         public  mpsub
  25. mpsub   proc    near
  26.  
  27.         push    di                      ; save address of result
  28.         clc                             ; carry initially clear
  29.  
  30. mpsub1: lodsb                           ; next byte from source
  31.         sbb     byte ptr es:[di],al     ; subtract from destination
  32.         inc     di
  33.         loop    mpsub1                  ; until all bytes processed
  34.  
  35.         pop     di                      ; restore address of result
  36.         ret                             ; back to caller
  37.  
  38. mpsub   endp
  39.  
  40. _TEXT   ends
  41.  
  42.         end
  43.  
  44.